package com.ptbuy.share;

import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class ShareUtils {
    public static void shareToWeChat(String text, Context context) {
        try {
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_TEXT, text);
            shareIntent.setType("text/plain");
            shareIntent.setPackage("com.tencent.mm"); // 微信包名
            context.startActivity(Intent.createChooser(shareIntent, "分享内容"));
        } catch (Exception e) {
            Toast.makeText(context,"微信分享失败，请检查是否安装微信",Toast.LENGTH_SHORT).show();
        }
    }


    public static void shareToQQ(String content, Context context) {
        try {
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_TEXT, content);
            shareIntent.setType("text/plain");
            shareIntent.setPackage("com.tencent.mobileqq"); // QQ包名
            context.startActivity(shareIntent);
        } catch (Exception e) {
            Toast.makeText(context,"QQ分享失败，请检查是否安装QQ",Toast.LENGTH_SHORT).show();
        }
    }
}
